﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DAL;
using System.Data;
using Public;
namespace BUL
{
    public class LoyaltyCardBUL
    {
        private LoyaltyCardDAL DAO;
        
        public LoyaltyCardBUL()
        {
            DAO = new LoyaltyCardDAL();
        }

        public bool AddNewCard(string cusname, string email,string identity, string phone,bool subcribe)
        {
            if (DAO.InsertCard(cusname, email, identity, phone, subcribe) > 0)
            {
                
                return true;
            }
            else
            {
                return false;
            }
            
        }

        public DataTable LoadAll()
        {
            return DAO.LoadAll();
        }

        public DataTable LoadSearch(string searchKey)
        {
            return DAO.LoadSearch(searchKey);
        }

        public bool UpdateCard(int cardId, string email, string phone,bool subcribe)
        {


            if (DAO.UpdateCard(cardId,email,phone,subcribe)>0)
            {

                return true;
            }
            else
            {
                return false;
            }
        }

        public bool CheckExisted(string name, string value)
        {
            return DAO.CheckDuplicate(name, value);
        }
        public int saveAdvertedCus(AdvertedCus advertedCus)
        {
            return DAO.saveAdvertedCus(advertedCus);
        }
    }
}
